How To Build GNU Screen for ARM


Intro


In this How To we are going to build screen 4.8 with our GCC 4.8.2 cross-compiler. Be sure to start this build in a new terminal/tab to avoid any pollution from previous builds.

Screen is another fantastic CLI tool. I use it everyday and had to have it for arm. Take a look here for a great way to use screen. RTFM ;-)

Tar Balls


Here is a list of source packages that we'll need for the build. You can either download them now or wait 'til later in the How To.
  • screen-4.0.3.tar.gz
  • configure.patch

You'll need Ncurses for this build.

Create a Workspace


I recommend creating a workspace under your /home/<your user>/ directory that is dedicated to this build. So let's fire up your terminal and run the following:
$ export SCREEN_SRC=~/workbench/screen/src
$ export SCREEN_BUILD=~/workbench/screen/build
$ mkdir -pv ~/workbench/screen
$ mkdir $SCREEN_SRC && mkdir $SCREEN_BUILD
$ cd $SCREEN_SRC

Gather the Sources


Now that we have a workspace created and we are currently in the src directory we can begin bringing down the sources and extracting them.

screen

$ wget http://ftp.gnu.org/gnu/screen/screen-4.0.3.tar.gz
$ tar -pxzf screen-4.0.3.tar.gz

patch

Follow the directions here and then do the following:
$ cd screen-4.0.3/
$ patch -p1 -i ../configure.patch configure && cd ..

Build Environment


To make things a little smoother let's setup some environment variables:
$ export INSTALLDIR=~/workbench/gcc-4.8.2/arm
$ export PATH=$INSTALLDIR/bin:$PATH
$ export TARGETMACH=arm-none-linux-gnueabi
$ export BUILDMACH=i686-pc-linux-gnu
$ export CROSS=arm-none-linux-gnueabi
$ export CC=${CROSS}-gcc
$ export LD=${CROSS}-ld
$ export AS=${CROSS}-as
NOTE: Depending on whether you are using a cross-compiler built from my other wikis you might need to change INSTALLDIR to point to your cross-compiler.

Build Screen


HACK ALERT! This is one of the worst hacks I've had to do for a build, yes there has been others >_<
cd ../build/
 
!!! This is a doozy !!!
First build for your native platform, in *my* case x86_64:
 
$ ../src/screen-4.0.3/./configure
$ make
$ mkdir x86_64
 
Move all of the created files/directory into x86_64 directory, this is your template
 
 
Now build for ARM:
 
$ mkdir arm.bkp
$ ../src/screen-4.0.3/./configure --prefix=/home/<your user>/workbench/screen/final --host=$TARGETMACH --enable-colors256
 
Move all of the created files/directory into arm.bkp directory, this is your backup
Now you need to modify the ARM main Makefile, config.h, and the "Output variables." and "confdefs.h." in config.log to match the x86_64 equivalents.
Next, copy & paste these from arm.bkp directory to ../build. Once that is done run:
 
$ make LDFLAGS+=-L/home/<your user>/workbench/ncurses/final/lib CPPFLAGS+=-I/home/<your user>/workbench/ncurses/final/include
 
Change, in config.h, from:
 
# define SCREENENCODINGS "/usr/share/screen/utf8encodings"
 
to:
 
# define SCREENENCODINGS "/home/<your user>/workbench/screen/final/usr/share/screen/utf8encodings"
 
 
$ make install LDFLAGS+=-L/home/<your user>/workbench/ncurses/final/lib CPPFLAGS+=-I/home/<your user>/workbench/ncurses/final/include
Good Luck! :)

Output


cd into the final directory and output its contents:
$ cd ../final/
$ ls
You should have the following directories:
  • bin
  • info
  • man
  • usr

Make sure the binaries are for ARM:
$ cd bin/
$ file screen-4.0.3
bash: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
If you see something *similar* to above you're good to go ;-)

Lastly, move the contents of these directories, or the directories themselves if they do not already exist, to your custom Linux file system or dev board.




Patch


Copy & paste the contents below in to a plain text file. Save the file as configure.patch to screen's src directory. You know, the directory that has screen's source code (SCREEN_SRC). The source of this patch can be found here.
*** configure    Fri Dec  5 13:46:53 2003
--- configure.new    Thu Jan 20 09:57:21 2011
***************
*** 2704,2710 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 2704,2710 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 2753,2759 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 2753,2759 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 2800,2806 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 2800,2806 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 4149,4155 ****
 
  { { echo "$as_me:$LINENO: error: !!! no select - no screen" >&5
  echo "$as_me: error: !!! no select - no screen" >&2;}
!    { (exit 1); exit 1; }; }
  fi
  rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
--- 4149,4155 ----
 
  { { echo "$as_me:$LINENO: error: !!! no select - no screen" >&5
  echo "$as_me: error: !!! no select - no screen" >&2;}
!    }
  fi
  rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
***************
*** 4163,4169 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 4163,4169 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 4272,4278 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 4272,4278 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 4365,4371 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 4365,4371 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 4460,4466 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 4460,4466 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 4562,4568 ****
  else
    { { echo "$as_me:$LINENO: error: you have neither usable sockets nor usable pipes -> no screen" >&5
  echo "$as_me: error: you have neither usable sockets nor usable pipes -> no screen" >&2;}
!    { (exit 1); exit 1; }; }
  fi
 
 
--- 4562,4568 ----
  else
    { { echo "$as_me:$LINENO: error: you have neither usable sockets nor usable pipes -> no screen" >&5
  echo "$as_me: error: you have neither usable sockets nor usable pipes -> no screen" >&2;}
!    }
  fi
 
 
***************
*** 4573,4579 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 4573,4579 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 4898,4904 ****
 
  { { echo "$as_me:$LINENO: error: !!! no tgetent - no screen" >&5
  echo "$as_me: error: !!! no tgetent - no screen" >&2;}
!    { (exit 1); exit 1; }; }
  fi
  rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
  fi
--- 4898,4904 ----
 
  { { echo "$as_me:$LINENO: error: !!! no tgetent - no screen" >&5
  echo "$as_me: error: !!! no tgetent - no screen" >&2;}
!    }
  fi
  rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
  fi
***************
*** 4915,4921 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 4915,4921 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 5359,5365 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 5359,5365 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 6206,6212 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 6206,6212 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 6482,6488 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 6482,6488 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 7004,7010 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 7004,7010 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 7056,7062 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 7056,7062 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 7110,7116 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 7110,7116 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
***************
*** 7951,7957 ****
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    { (exit 1); exit 1; }; }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
--- 7951,7957 ----
  See \`config.log' for more details." >&5
  echo "$as_me: error: cannot run test program while cross compiling
  See \`config.log' for more details." >&2;}
!    }
  else
    cat >conftest.$ac_ext <<_ACEOF
  #line $LINENO "configure"
 
You should have the following directories:
Make sure the binaries are for ARM: